﻿var viewModelFunnelReport = new function () {
    this.viewType = ko.observable(data.ViewType != null ? data.ViewType : "ByUser");
    this.LeadSource = ko.observableArray(data.ListLeadFunnelBy);
    this.LeadOption = ko.observable(data.LeadTypeId != null ? data.LeadTypeId : data.ListLeadFunnelBy[0].Id);
    this.StartDate = ko.observable(data.StartDate);
    this.EndDate = ko.observable(data.EndDate);
    this.SortOrder = ko.observable("asc");

    this.LeadSourceSelected = ko.computed(function () {
        return true;
    }, this);

    this.GoFilter = function () {
        var locationUrl = "/Reporting/LeadFunnel?startDate=" + this.StartDate();
        locationUrl = locationUrl + "&endDate=" + this.EndDate();
        locationUrl = locationUrl + "&leadType=" + this.LeadOption();
        locationUrl = locationUrl + "&viewType=" + this.viewType();
        locationUrl = locationUrl + "&pageSize=50";
        locationUrl = locationUrl + "&pageIndex=1";
        locationUrl = locationUrl + "&sortOrder=asc";

        window.location.href = locationUrl;
    }
};

ko.applyBindings(viewModelFunnelReport, document.getElementById("viewFunnel"));